浏览量 4253
2016/03/31 13:13
示例:点击 -> 性能监控
通过df命令统计:
[root@wangzi go]# df |grep -v ^Filesystem|awk -F ' ' '{print $6"|"$3"|"$4}'
/|6999556|42168392
/dev|0|498596
/dev/shm|24|508080
/run|412|507692
/sys/fs/cgroup|0|508104
/run/user/0|0|101624
python代码:
#!/usr/bin/env python
# coding=utf-8
# author: brownwang
# mail: 277215243@qq.com
# datetime:2019/3/31 1:03 PM
# web: https://www.bthlt.com
from subprocess import Popen,PIPE
def disk_df():
ret=Popen("""df |grep -v ^Filesystem|awk -F ' ' '{print $6"|"$3"|"$4}'""",shell=True,stdout=PIPE)
for item in ret.stdout.readlines():
disk_info=item.replace('\n','').split('|')
insert_sql="""insert into `monitor_disk_df` (`path`,`used`,`idle`,`flow_time`) values ('{0}',{1},{2},'{3}')""".format(disk_info[0],disk_info[1],disk_info[2],now_zero)
cursorUpdate(insert_sql,[])
上一篇 搜索 下一篇